﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DTO;

namespace DA
{
    public class LoaiSPDB
    {
        public List<LoaiSPData> getAllLoaiSanPham()
        {
            List<LoaiSPData> list = new List<LoaiSPData>();
            ConnectionDB cn = new ConnectionDB();
            LoaiSPData data = null;
            string sql = "Select * from LoaiSP";
            cn.Cmd.CommandText = sql;
            SqlDataReader reader = cn.Cmd.ExecuteReader();
            if(reader.HasRows)
            {
                while(reader.Read())
                {
                    data = new LoaiSPData();
                    data.MaLoai = reader.GetInt32(0);
                    data.TenLoai = reader.GetString(1);
                    list.Add(data);
                }
            }
            return list;
        }
    }
}
